<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <include file="Public/meta"/>
</head>
<body>

    <div class="info-center">
        <!--顶部面包屑-->
        <div class="page-header">
            <div class="pull-left">
                <h4>文章分类列表:</h4>
            </div>
            <a href="javascript:;" class="btn btn-primary pull-right margin-top" onclick="add()">新增一个文章分类</a>
        </div>

        <div class="clearfix"></div>
        <!--表格数据-->
        <div class="table-margin">
            <table class="table table-hover table-header" id="list-table">
                <thead>
                <tr>
                    <td style="width: 100px;">编号</td>
                    <td style="width: 180px;" align="center">分类名称</td>
                    <td style="width: 200px;" align="center">启用状态</td>
                    <td style="width: 100px;" align="center">添加时间</td>
                    <td align="center" class="w10">操作</td>
                </tr>
                </thead>
                <tbody>
                <foreach name="list" item="vo">
                    <tr>
                        <td>{$vo['id']}</td>
                        <td align="center">{$vo['name']}</td>
                        <td align="center">{$vo['state']}</td>
                        <td align="center">{$vo['add_time']}</td>
                        <td style="width: 100px;" align="center">
                            <a href="javascript:;"
                               id="{$vo['id']}"
                               name="{$vo['name']}"
                               state="{$vo['state']}"
                               onclick="edit(this)">
                                编辑
                            </a>
                            <span class="text-explode">|</span>
                            <a href="javascript:if(confirm('确定删除？')) location ='{:U('article/delarticlecat',array('id'=>$vo['id']))}'">删除</a>
                        </td>
                    </tr>
                </foreach>
                </tbody>
            </table>
        </div>

    </div>

    <!--新增时候显示编辑对话框-->
    <div class="modal fade" id="xz-edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h4 class="modal-title" id="myModalLabel"> 新增文章分类</h4>
                </div>
                <div class="modal-body">
                    <form id="xz-form" class="form-horizontal" action="{:U('article/addarticlecat')}" method="post">
                        <table class="table table-hover contact-template-form">
                            <tbody>
                            <tr>
                                <td width="20%" align="right">分类名称：</td>
                                <td>
                                    <input class="form-control w-300" type="text" name="name">
                                </td>
                            </tr>
                            <tr>
                                <td width="20%" align="right">启用状态：</td>
                                <label>
                                    <span class="inputword">开启</span>
                                    <input checked="checked" class="xb-icheck" type="radio" name="state" value="1" <eq name="info['state']" value="1"> checked="checked"</eq> >
                                </label>
                                <label>
                                    <span class="inputword">关闭</span>
                                    <input class="xb-icheck" type="radio" name="state" value="0" <eq name="info['state']" value="0"> checked="checked"</eq> >
                                </label>

                            </tr>
                            <tr>
                                <th></th>
                                <td>
                                    <input class="btn btn-primary" type="submit" value="确认">
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </form>
                </div>
            </div>
        </div>
    </div>

    <!--编辑时候显示编辑对话框-->
    <div class="modal fade" id="bj-edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h4 class="modal-title" id="myModalLabel"> 修改分类</h4>
                </div>
                <div class="modal-body">
                    <form id="bj-form" class="form-horizontal" action="{:U('article/articlecat')}" method="post">
                        <table class="table table-hover contact-template-form">
                            <tbody>
                            <tr>
                                <td width="20%" align="right">分类编号：</td>
                                <td>
                                    <input class="form-control w-300" type="text" name="cat_id" readonly="readonly">
                                </td>
                            </tr>
                            <tr>
                                <td width="20%" align="right">分类名称：</td>
                                <td>
                                    <input class="form-control w-300" type="text" name="cat_name">
                                </td>
                            </tr>
                            <tr>
                                <td width="20%" align="right">启用状态：</td>
                                <label>
                                    <span class="inputword">开启</span>
                                    <input checked="checked" class="xb-icheck" type="radio" name="cat_state" value="1" <eq name="info['state']" value="1"> checked="checked"</eq> >
                                </label>
                                <label>
                                    <span class="inputword">关闭</span>
                                    <input class="xb-icheck" type="radio" name="cat_state" value="0" <eq name="info['state']" value="0"> checked="checked"</eq> >
                                </label>

                            </tr>
                            <tr>
                                <th></th>
                                <td>
                                    <input class="btn btn-primary" type="submit" value="确认">
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </form>
                </div>
            </div>
        </div>
    </div>

    <script type="text/javascript" src="__ADMIN_JS__/common.js"></script>
    <script>
        // 修改文章分类
        function edit(obj) {
            var id = $(obj).attr('id');
            var name = $(obj).attr('name');
            var state = $(obj).attr('state');
            if(state == "启用"){
                state = 1;
            }else {
                state = 0;
            }
            //todo... 不能实时改变单选框状态信息

            $("input[name='cat_id']").val(id);
            $("input[name='cat_name']").val(name);
            $("input[name='cat_state']").val(state);
            $('#bj-edit').modal('show');
        }

        // 新增文章分类
        function add() {
            $('#xz-edit').modal('show');
        }



    </script>


</body>
</html>